<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Spring和SpringBoot区别 | Xuan的博客</title><meta name="author" content="Xuan"><meta name="copyright" content="Xuan"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Spring和SpringBoot区别整合Mybatis的作用MyBatis 可以帮助我们连接数据库，执行 SQL，返回结果集，通过接口的形式进行开发，但是不需要定义接口的实现类，而是用一个 XML 文件与接口进行对接，接口方法的 SQL 语句直接定义到 XML 文件中。 SpringBoot是如何装载Mybatis的Spring Boot 启动的时候会自动加载到 Mapper 接口，以及对应的">
<meta property="og:type" content="article">
<meta property="og:title" content="Spring和SpringBoot区别">
<meta property="og:url" content="http://leesmile.gitee.io/smile/2023/07/10/Java/SpringBoot/SpringBoot%E6%95%B4%E5%90%88Mybatis/index.html">
<meta property="og:site_name" content="Xuan的博客">
<meta property="og:description" content="Spring和SpringBoot区别整合Mybatis的作用MyBatis 可以帮助我们连接数据库，执行 SQL，返回结果集，通过接口的形式进行开发，但是不需要定义接口的实现类，而是用一个 XML 文件与接口进行对接，接口方法的 SQL 语句直接定义到 XML 文件中。 SpringBoot是如何装载Mybatis的Spring Boot 启动的时候会自动加载到 Mapper 接口，以及对应的">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg">
<meta property="article:published_time" content="2023-07-10T01:53:47.000Z">
<meta property="article:modified_time" content="2023-07-10T01:53:47.000Z">
<meta property="article:author" content="Xuan">
<meta property="article:tag" content="Java">
<meta property="article:tag" content="SpringBoot">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg"><link rel="shortcut icon" href="/smile/img/favicon.png"><link rel="canonical" href="http://leesmile.gitee.io/smile/2023/07/10/Java/SpringBoot/SpringBoot%E6%95%B4%E5%90%88Mybatis/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/smile/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/smile/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Spring和SpringBoot区别',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-10 09:53:47'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/font.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/whiteLine.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/progress_bar.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/cat.css"><link rel="stylesheet" href="/css/readPercent.css"><link rel="stylesheet" href="https://cdn1.tianli0.top/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"><div id="myscoll"></div><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg')"><nav id="nav"><span id="blog-info"><a href="/smile/" title="Xuan的博客"><span class="site-name">Xuan的博客</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="nav-right"><a class="meihua faa-parent animated-hover" onclick="toggleWinbox()" title="美化设置-自定义你的风格" id="meihua-button"><svg class="faa-tada icon" style="height:26px;width:26px;fill:currentColor;position:relative;top:8px" aria-hidden="true"><use xlink:href="#icon-tupian1"></use></svg></a><a class="sun_moon faa-parent animated-hover" onclick="switchNightMode()" title="浅色和深色模式转换" id="nightmode-button"><svg class="faa-tada" style="height:25px;width:25px;fill:currentColor;position:relative;top:7px" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Spring和SpringBoot区别</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-10T01:53:47.000Z" title="发表于 2023-07-10 09:53:47">2023-07-10</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-10T01:53:47.000Z" title="更新于 2023-07-10 09:53:47">2023-07-10</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/smile/categories/Java/">Java</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/smile/categories/Java/SpringBoot/">SpringBoot</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Spring和SpringBoot区别"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section><div id="post-top-cover"><img class="nolazyload" id="post-top-bg" src="background-image: url('https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg')"></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Spring和SpringBoot区别"><a href="#Spring和SpringBoot区别" class="headerlink" title="Spring和SpringBoot区别"></a>Spring和SpringBoot区别</h1><h4 id="整合Mybatis的作用"><a href="#整合Mybatis的作用" class="headerlink" title="整合Mybatis的作用"></a>整合Mybatis的作用</h4><p>MyBatis 可以帮助我们连接数据库，执行 SQL，返回结果集，通过接口的形式进行开发，但是不需要定义接口的实现类，而是用一个 XML 文件与接口进行对接，接口方法的 SQL 语句直接定义到 XML 文件中。</p>
<h4 id="SpringBoot是如何装载Mybatis的"><a href="#SpringBoot是如何装载Mybatis的" class="headerlink" title="SpringBoot是如何装载Mybatis的"></a>SpringBoot是如何装载Mybatis的</h4><p>Spring Boot 启动的时候会自动加载到 Mapper 接口，以及对应的 XML 文件，会自动生成一个代理类（相当于手写的实现类），并且会创建代理对象，注入到 IoC 中，可以直接取出来使用。</p>
<p>Spring Boot 之所以能自动加载组件，它的工作流程是，启动之后扫描第三方框架的 META-INF&#x2F;spring.factories，该文件中就配置了该框架所需要自动装载的类信息，Spring Boot 就是由此获取到类信息的</p>
<p>基于配置类的形式，用类取代 XML 文件</p>
<h4 id="项目创建方式"><a href="#项目创建方式" class="headerlink" title="项目创建方式"></a>项目创建方式</h4><ol>
<li><p>官网创建项目: 从<a target="_blank" rel="noopener" href="https://start.spring.io/">spring initializr</a>官方创建</p>
<p>选择maven，java及java版本号</p>
<p>选择石侧Dependencies的ADD DEPENDENCIES添加Spring Web</p>
<p>填写对应的Project Metadata</p>
<p>下载后，解压，idea打开即可，等待包的导入。</p>
</li>
<li><p>通过IDEA选择Spring Initializr创建</p>
</li>
<li><p>通过Maven创建</p>
<p>导入Spring依赖，手动创建Application方法，类上使用<code>@SpringBootApplication</code></p>
<p>创建main方法，调用SpringApplication的run方法，传入启动类的.class对象</p>
</li>
</ol>
<h4 id="运行方式"><a href="#运行方式" class="headerlink" title="运行方式"></a>运行方式</h4><p>通过Idea界面启动</p>
<p>通过命令行启动</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Mvn命令启动  mvn spring-boot:run</span><br><span class="line"></span><br><span class="line">java命令启动  java -jar jar包</span><br></pre></td></tr></table></figure>

<h4 id="配置文件"><a href="#配置文件" class="headerlink" title="配置文件"></a>配置文件</h4><p>端口号配置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">​```YAML</span><br></pre></td></tr></table></figure>

<p>server:  port: 8080</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">    通过java命令</span><br><span class="line"></span><br><span class="line">      `java -jar -Dserver.port=端口号 jar包`</span><br><span class="line"></span><br><span class="line">    完整配置文件application.yml</span><br><span class="line"></span><br><span class="line">      ```YAML</span><br><span class="line">server:</span><br><span class="line">  port: 8080</span><br><span class="line">spring:</span><br><span class="line">  datasource:</span><br><span class="line">    driver-class-name: com.mysql.cj.jdbc.Driver</span><br><span class="line">    url: jdbc:mysql://localhost:3306/test</span><br><span class="line">    username: root</span><br><span class="line">    password: 123456</span><br><span class="line">  thymeleaf:</span><br><span class="line">    prefix: classpath:/templates/</span><br><span class="line">    suffix: .html</span><br><span class="line">mybatis:</span><br><span class="line">  configuration:</span><br><span class="line">#    use-actual-param-name: true</span><br><span class="line">    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl</span><br><span class="line">#  mapper-locations: classpath:mapping/*.xml</span><br><span class="line">#  type-aliases-package: com.example.entity</span><br><span class="line">mybatis-plus:</span><br><span class="line">  mapper-locations: classpath:com/example/mapper/*.xml</span><br></pre></td></tr></table></figure>

<h4 id="发送请求方式"><a href="#发送请求方式" class="headerlink" title="发送请求方式"></a>发送请求方式</h4><ol>
<li>创建与前端请求交互的包 <code>controller</code></li>
<li>在包下创建与first请求交互的类</li>
<li>在 类上添注解<code>RestController</code>说明这是一个和web请求交互的类</li>
<li>在类内编写请求方法</li>
<li>在方法上添加<code>GET</code>请求注解及其请求路径</li>
<li>启动服务，浏览器输入验证</li>
</ol>
<h4 id="请求注解有两种方式"><a href="#请求注解有两种方式" class="headerlink" title="请求注解有两种方式"></a>请求注解有两种方式</h4><ol>
<li>通过<code>@GetMapping @PostMapping</code>等注解的方式<ol>
<li>value参数表示路径，produces参数表示参数类型</li>
</ol>
</li>
<li>通过<code>@RequestMapping(method = RequestMethod.GET)</code>声明请求方式</li>
</ol>
<h4 id="请求参数传递方式"><a href="#请求参数传递方式" class="headerlink" title="请求参数传递方式"></a>请求参数传递方式</h4><ol>
<li><code>@PathVariable</code>路径参数<ul>
<li>name&#x2F;value</li>
<li>要绑定的请求参数的名称，跟<code>URI</code>上填写的路径名一样</li>
<li>required</li>
<li>含义：请求参数是否必填</li>
<li>默认<code>true</code></li>
<li>请求缺少参数会引发异常<ul>
<li>请求中不存在参数或参数为<code>null</code></li>
</ul>
</li>
</ul>
</li>
<li><code>@RequestParam</code>Param拼接参数<ul>
<li>name&#x2F;value</li>
<li>要绑定的请求参数的名称，跟<code>URL</code>上一样</li>
<li>defaultValue</li>
<li>请求参数未提供或空时的默认值</li>
<li>提供默认值会隐式地将 <code>required</code> 设置为 <code>false</code></li>
<li>required</li>
<li>含义：请求参数是否必填</li>
<li>默认<code>true</code></li>
<li>请求缺少参数会引发异常<ul>
<li>请求中不存在参数或参数为<code>null</code></li>
<li>1）<code>required</code>声明为<code>false</code></li>
<li>2）提供<code>defaultValue</code></li>
</ul>
</li>
</ul>
</li>
<li><code>@RequestBody</code>请求体<ol>
<li><code>produces</code>参数标注请求参数类型</li>
<li>传递Json格式参数<code>MediaType.APPLICATION_JSON_VALUE</code></li>
<li>传递Xml格式参数<code>MediaType.APPLICATION_XML_VALUE</code></li>
<li><code>required</code>参数</li>
<li>是否必传参数校验</li>
<li>注意：body提交方式如果选择的不是json则报415</li>
</ol>
</li>
</ol>
<h4 id="注解"><a href="#注解" class="headerlink" title="注解"></a>注解</h4><ol>
<li>@<code>Controller</code></li>
<li>@<code>Service</code></li>
<li><code>@Repository</code></li>
<li><code>@Mapper</code></li>
<li><code>@MapperScan</code></li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>Spring和SpringBoot区别</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="http://leesmile.gitee.io/smile/2023/07/10/Java/SpringBoot/SpringBoot%E6%95%B4%E5%90%88Mybatis/">http://leesmile.gitee.io/smile/2023/07/10/Java/SpringBoot/SpringBoot整合Mybatis/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>Xuan</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2023-07-10</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2023-07-10</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/smile/tags/Java/">Java</a><a class="post-meta__tags" href="/smile/tags/SpringBoot/">SpringBoot</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/smile/2023/07/11/Java/SpringBoot/Swagger/" title="Swagger"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" onerror="onerror=null;src='/smile/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Swagger</div></div></a></div><div class="next-post pull-right"><a href="/smile/2023/07/10/Java/SpringBoot/SpringBoot%20%E6%95%B4%E5%90%88%E6%8C%81%E4%B9%85%E5%B1%82%E6%A1%86%E6%9E%B6/" title="Spring和SpringBoot区别"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" onerror="onerror=null;src='/smile/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Spring和SpringBoot区别</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/smile/2023/07/10/Java/SpringBoot/SpringBoot/" title="SpringBoot"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-10</div><div class="title">SpringBoot</div></div></a></div><div><a href="/smile/2023/07/10/Java/SpringBoot/SpringBoot%20%E6%95%B4%E5%90%88%E6%8C%81%E4%B9%85%E5%B1%82%E6%A1%86%E6%9E%B6/" title="Spring和SpringBoot区别"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-10</div><div class="title">Spring和SpringBoot区别</div></div></a></div><div><a href="/smile/2023/10/10/Java/SpringBoot/SpringBoot%E6%A0%B9%E6%8D%AE%E9%85%8D%E7%BD%AE%E6%B3%A8%E5%85%A5Bean%EF%BC%9A@ConditionalOnProperty/" title="SpringBoot根据配置注入Bean：@ConditionalOnProperty"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-10-10</div><div class="title">SpringBoot根据配置注入Bean：@ConditionalOnProperty</div></div></a></div><div><a href="/smile/2023/07/11/Java/SpringBoot/Spring%E5%92%8CSpringBoot%E5%8C%BA%E5%88%AB/" title="Spring和SpringBoot区别"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-11</div><div class="title">Spring和SpringBoot区别</div></div></a></div><div><a href="/smile/2023/07/11/Java/SpringBoot/Swagger/" title="Swagger"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611564.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-11</div><div class="title">Swagger</div></div></a></div><div><a href="/smile/2023/06/09/Java/DbUtil/" title="DbUtil"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-06-09</div><div class="title">DbUtil</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="author_top is-center"><div class="avatar-img"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="this.onerror=null;this.src='/smile/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Xuan</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Spring%E5%92%8CSpringBoot%E5%8C%BA%E5%88%AB"><span class="toc-number">1.</span> <span class="toc-text">Spring和SpringBoot区别</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%95%B4%E5%90%88Mybatis%E7%9A%84%E4%BD%9C%E7%94%A8"><span class="toc-number">1.0.0.1.</span> <span class="toc-text">整合Mybatis的作用</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#SpringBoot%E6%98%AF%E5%A6%82%E4%BD%95%E8%A3%85%E8%BD%BDMybatis%E7%9A%84"><span class="toc-number">1.0.0.2.</span> <span class="toc-text">SpringBoot是如何装载Mybatis的</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%A1%B9%E7%9B%AE%E5%88%9B%E5%BB%BA%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.3.</span> <span class="toc-text">项目创建方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.4.</span> <span class="toc-text">运行方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">1.0.0.5.</span> <span class="toc-text">配置文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8F%91%E9%80%81%E8%AF%B7%E6%B1%82%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.6.</span> <span class="toc-text">发送请求方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AF%B7%E6%B1%82%E6%B3%A8%E8%A7%A3%E6%9C%89%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.7.</span> <span class="toc-text">请求注解有两种方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.8.</span> <span class="toc-text">请求参数传递方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%B3%A8%E8%A7%A3"><span class="toc-number">1.0.0.9.</span> <span class="toc-text">注解</span></a></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="不同角度出发去需求沟通问题"/></a><div class="content"><a class="title" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题">不同角度出发去需求沟通问题</a><time datetime="2024-04-08T07:55:46.000Z" title="发表于 2024-04-08 15:55:46">2024-04-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="产品商业计划方向思考"/></a><div class="content"><a class="title" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考">产品商业计划方向思考</a><time datetime="2024-04-01T07:55:46.000Z" title="发表于 2024-04-01 15:55:46">2024-04-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="公司自动化测试落地的难点"/></a><div class="content"><a class="title" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点">公司自动化测试落地的难点</a><time datetime="2024-03-28T07:55:46.000Z" title="发表于 2024-03-28 15:55:46">2024-03-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="异步任务的体验关键在交互设计"/></a><div class="content"><a class="title" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计">异步任务的体验关键在交互设计</a><time datetime="2024-03-22T07:55:46.000Z" title="发表于 2024-03-22 15:55:46">2024-03-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310261354386.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Git工作流"/></a><div class="content"><a class="title" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流">Git工作流</a><time datetime="2024-03-11T07:55:46.000Z" title="发表于 2024-03-11 15:55:46">2024-03-11</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By Xuan</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i><span id="percent">0<span>%</span></span></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div><script src="/smile/js/utils.js"></script><script src="/smile/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async src="https://cdn1.tianli0.top/npm/vue@2.6.14/dist/vue.min.js"></script><script async src="https://cdn1.tianli0.top/npm/element-ui@2.15.6/lib/index.js"></script><script defer src="/js/cursor.js"></script><script async src="//npm.elemecdn.com/pace-js@1.2.4/pace.min.js"></script><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/cat.js"></script><script defer data-pjax src="/js/readPercent.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="width:100%;height: auto"><div id="catalog_magnet"><a class="magnet_link_more"  href="http://leesmile.gitee.io/smile/categories" style="flex:1;text-align: center;margin-bottom: 10px;">查看更多...</a></div></div>';
    console.log('已挂载magnet')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script><style>#catalog_magnet{flex-wrap: wrap;display: flex;width:100%;justify-content:space-between;padding: 10px 10px 0 10px;align-content: flex-start;}.magnet_item{flex-basis: calc(50% - 5px);background: #87CEFA;margin-bottom: 10px;border-radius: 8px;transition: all 0.2s ease-in-out;}.magnet_item:hover{background: #00FFFF}.magnet_link_more{color:#555}.magnet_link{color:black}.magnet_link:hover{color:white}@media screen and (max-width: 600px) {.magnet_item {flex-basis: 100%;}}.magnet_link_context{display:flex;padding: 10px;font-size:16px;transition: all 0.2s ease-in-out;}.magnet_link_context:hover{padding: 10px 20px;}</style>
    <style></style><script data-pjax>
  function butterfly_footer_beautify_injector_config(){
    var parent_div_git = document.getElementById('footer-wrap');
    var item_html = '<div id="workboard"></div><p id="ghbdages"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" data-title="博客框架为Hexo_v6.2.0" title=""><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" data-title="主题版本Butterfly_v4.3.1" title=""><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt=""/></a><a class="github-badge" target="_blank" href="https://gitee.com/" style="margin-inline:5px" data-title="本站项目由Gitee托管" title=""><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&amp;logo=GitHub" alt=""/></a><a class="github-badge" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" data-title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可" title=""><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt=""/></a></p>';
    console.log('已挂载butterfly_footer_beautify')
    parent_div_git.insertAdjacentHTML("beforeend",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_footer_beautify_injector_config();
  }
  else if (epage === cpage){
    butterfly_footer_beautify_injector_config();
  }
  </script><script async src="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.js"></script><!-- hexo injector body_end end --></body></html>